<%@page language="java" contentType="text/html; charset=UTF-8" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="html" tagdir="/WEB-INF/tags" %>
<!DOCTYPE html>
<html>
<html:header title="新增转账">

    <link rel="stylesheet" href="${baseUrl}css/public.css" media="all">
    <style type="text/css">
        .readonly{
            background-color: #eeeeee;
        }

    </style>
    <script>
        jQuery(function () {
            ajaxSelect("${baseUrl}user/user/getAll.action", "userId");

            ajaxSelect("${baseUrl}organization/store/getStores.action","storeId");
            ajaxSelects("${baseUrl}settAccount/settAccount/listVo.action",[
                {selectName:"outSettAccountId"},
                {selectName:"inSettAccountId" }]);

            $("#cancel").click(function () {
                closeSubIframe();
            });

            $("[name='amt']").blur(function () {
                let amt = $(this).val();
                if (amt != ""){
                    amt = getPrice(amt);
                    $(this).val(amt);
                }
            });

            $("[name='handleFee']").blur(function () {
                let amt = $(this).val();
                if (amt != ""){
                    amt = getPrice(amt);
                    $(this).val(amt);
                }
            });
        });

        layui.use(['form', 'table','laydate'], function () {
            var $ = layui.jquery,
                form = layui.form,
                laydate = layui.laydate,
                table = layui.table;

            //日期
            laydate.render({
                elem: '#outDate'
            });

            //日期
            laydate.render({
                elem: '#inDate'
            });

            form.verify({
                storeId: function(value, item){ //value：表单的值、item：表单的DOM对象
                    if(value == null || value==""){
                        return '门店不能为空';
                    }
                },
                inSettAccountId: function(value, item){ //value：表单的值、item：表单的DOM对象
                    if(value == null || value==""){
                        return '转入账户不能为空';
                    }
                },
                outSettAccountId: function(value, item){ //value：表单的值、item：表单的DOM对象
                    if(value == null || value==""){
                        return '转出账户不能为空';
                    }
                },
                amt: function(value, item){ //value：表单的值、item：表单的DOM对象
                    if(value == null || value==""){
                        return '金额不能为空';
                    }
                },
                userId: function(value, item){ //value：表单的值、item：表单的DOM对象
                    if(value == null || value==""){
                        return '经办人不能为空';
                    }
                },

            });
            form.on('submit(save)', function (data) {
                data.field.inDate = genDate(data.field.inDate);
                data.field.outDate = genDate(data.field.outDate);
                console.log(JSON.stringify(data.field));
                tipLoad("新增中...");
                post("${baseUrl}funds/transfer/add.action", data.field,function (resp) {
                    closeAll();
                    if (resp.code == 1) {
                        refreshMainIframe("${baseUrl}funds/transfer.action");
                        closeSubIframe();
                    } else {
                        errTip(resp.msg);
                    }
                });

                return false;
            });

        });
    </script>

</html:header>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form" id="addForm">
            <h3>转出信息</h3>
            <hr>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">转出账户</label>
                    <div class="layui-input-inline">
                        <select name="outSettAccountId" lay-verify="outSettAccountId"></select>
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">转出日期</label>
                    <div class="layui-input-inline">
                        <input type="text" name="outDate" id="outDate" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>


            <h3>转入信息</h3>
            <hr>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">转入账户</label>
                    <div class="layui-input-inline">
                        <select name="inSettAccountId" lay-verify="inSettAccountId"></select>
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">到账日期</label>
                    <div class="layui-input-inline">
                        <input type="text" name="inDate" id="inDate" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>

            <h3>基本信息</h3>
            <hr>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">门店</label>
                    <div class="layui-input-inline">
                        <select name="storeId" lay-verify="storeId">
                        </select>
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">经手人</label>
                    <div class="layui-input-inline">
                        <select name="userId" lay-verify="userId"></select>
                    </div>
                </div>
            </div>


            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">金额</label>
                    <div class="layui-input-inline">
                        <input type="number" name="amt" lay-verify="amt" class="layui-input">
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">手续费</label>
                    <div class="layui-input-inline">
                        <input type="number" name="handleFee" class="layui-input">
                    </div>
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <textarea name="remark" placeholder="备注" class="layui-textarea"></textarea>
                </div>
            </div>

            <button class="layui-btn" lay-submit lay-filter="save">确认</button>
            <button class="layui-btn layui-btn-primary" id="cancel">取消</button>
        </form>
    </div>
</div>

</body>
<html:loading/>

</html>